package com.cus.tom.transfer.trans.io;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;

import com.cus.tom.transfer.App;
import com.cus.tom.transfer.trans.service.AppService;

public class AppReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null) {
            return;
        }
        try {
            String s = intent.getDataString().substring(8);
            ApplicationInfo info = App.getApp().getPackageManager().getApplicationInfo(s, 0);
            String name = info.loadLabel(App.getApp().getPackageManager()).toString();
            Intent i = new Intent(context, AppService.class);
            i.putExtra("from", 1);
            i.putExtra("pkg", s);
            i.putExtra("name", name);
            context.startService(i);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
